package Reflect;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-10-15
 * Time: 11:28
 */
//创建字节码文件对象
public class CreateClassObject {
    public static void main(String[] args) throws ClassNotFoundException {
        //第一种:Class.forName("参数")  参数为 包名 + 类名 编译阶段获取
        Class<?> studentClass1 = Class.forName("Reflect.Student");

        //第二种:类名.class 类加载阶段获取
        Class<Student> studentClass2 = Student.class;

        //第三种:对象.getClass() 运行阶段获取
        Student student = new Student();
        Class<?> studentClass3 = student.getClass();

        System.out.println(studentClass1);
        System.out.println(studentClass2);
        System.out.println(studentClass3);

        if(studentClass1 == studentClass2 && studentClass2 == studentClass3){
            System.out.println("true");
        }
    }
}
